package acwing.图.二分图;
import java.util.Arrays;
import java.util.Scanner;

/**
 * 匈牙利算法
 *
 * @author yang
 * @date 2022/1/14
 */
public class 二分图的最大匹配 {
    static int N = 510;
    static int M = 100010;
    static int n1, n2, m, idx;
    static int[] e = new int[M];
    static int[] h = new int[M];
    static int[] ne = new int[M];
    static boolean[] st = new boolean[M];
    static int[] match = new int[N];

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        Arrays.fill(h, -1);
        n1 = sc.nextInt();
        n2 = sc.nextInt();
        m = sc.nextInt();
        while (m -- > 0) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            add(a, b);
        }
        int res = 0;
        for (int i = 1; i <= n1; i++) {
            Arrays.fill(st, false);
            if (find(i)) res++;
        }
        System.out.println(res);
    }

    private static boolean find(int x) {

        for (int i = h[x]; i != -1; i = ne[x]) {
            int j = e[i];
            if (!st[j]) {
                st[j] = true;
                // 没有匹配或者可以匹配别人
                if (match[j] == 0 || find(match[j])) {
                    match[j] = x;
                    return true;
                }
            }
        }
        return false;
    }

    private static void add(int x, int y) {
        e[idx] = y;
        ne[idx] = h[x];
        h[x] = idx++;
    }
}
